package com.example.fan.airline_reservation.Adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.fan.airline_reservation.Model.TicketList;
import com.example.fan.airline_reservation.R;
import com.example.fan.airline_reservation.traveler_ticketlist;

import java.util.List;


public class ticketlist_adapter extends ArrayAdapter<TicketList> {

    private int resourceId;
    public ticketlist_adapter(traveler_ticketlist context, int textViewResourceId, List<TicketList> object){
        super(context,textViewResourceId,object);
        resourceId=textViewResourceId;
    }
    public View getView(int position, View convertView, ViewGroup parent){

        TicketList ticketList=getItem(position);
        View view;
        if(convertView==null){
            view= LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        }
        else{
            view=convertView;
        }
        TextView starttime=view.findViewById(R.id.starttimeTL);
        TextView startplace=view.findViewById(R.id.startplaceTL);
        TextView arrivetime=view.findViewById(R.id.arrivetimeTL);
        TextView arriveplace=view.findViewById(R.id.arriveplaceTL);
        TextView price=view.findViewById(R.id.priceTL);
        TextView planemodel=view.findViewById(R.id.planeTL);
        TextView flytime=view.findViewById(R.id.flytimeTL);
        TextView flghtNO=view.findViewById(R.id.flightNO);
        Log.e("Adpter ticket list ",ticketList.getArriveplace());

        starttime.setText(ticketList.getStarttime());
        startplace.setText(ticketList.getStartplace());
        arrivetime.setText(ticketList.getArrivetime());
        arriveplace.setText(ticketList.getArriveplace());
        price.setText(ticketList.getPrice());
        planemodel.setText(ticketList.getPlanemodel());
        flytime.setText(ticketList.getFlytime());
        flghtNO.setText(ticketList.getFlightNO());
        return view;
    }
}
